//
//  LDMyResumeCellExpectJobInAll.swift
//  DingDongZP
//
//  Created by LeMac on 16/12/27.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class LDMyResumeCellExpectJobInAll: LDMyResumeBaseCellInAll {


    private var jobTitleLab:UILabel?
    private var statusLab:UILabel?
    private var phoneLab:UILabel?
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupView()
    }
    
    override func updateView() {
        
        
        jobTitleLab?.text = model?.expectjobcategory
        
        if model?.status != nil && model?.expectcity != nil {
            
            statusLab?.text = String(format: "%@  |  %@  %@", model?.status ?? "",model?.expectcity ?? "",model?.expectsalary ?? "")
        } else {
            statusLab?.text  = "期望工作未设置"
            statusLab!.snp_updateConstraints(closure: { (make) in
                
                make.centerY.equalTo(bgView!)
            })
        }
        
        
        let arrindustries  = model?.expectjobindustries ?? [AnyObject]()
        
        let arrindustriesstr = arrindustries.map { (obj) -> String in
            
            let dict = obj as? NSDictionary ?? NSDictionary()
            return dict["industry"] as? String ?? ""
        }
        
        var industriesstr = ""
        for (index,item) in arrindustriesstr.enumerate() {
            
            if index > 0 {
                
                industriesstr.appendContentsOf(" | " + item)
            } else {
                industriesstr.appendContentsOf(item)
            }
        }
        
        phoneLab?.text = industriesstr
    }
    
    func setupView() {
        
        title = "期望工作"
        jobTitleLab = UILabel.setDetailsLab("UI设计", fontSize: 16, titleColor: LDFontColor.BlackLight, Alignment: .Left)
        statusLab = UILabel.setDetailsLab("离职－随时到港 ｜ 杭州 ｜ 8K－10K", fontSize: 14, titleColor: LDFontColor.DeepGray, Alignment: .Left)
        phoneLab = UILabel.setDetailsLab("手机 ／ 数码 ／ 办公", fontSize: 14, titleColor: LDFontColor.DeepGray, Alignment: .Left)
        
        
        bgView?.addSubview(jobTitleLab!)
        bgView?.addSubview(statusLab!)
        bgView?.addSubview(phoneLab!)
        //
        
        
        jobTitleLab?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo(LDMargin_V*2)
            make.left.equalTo(LDMargin_V*3)
            make.height.equalTo(LDMargin_V*7)
            make.right.equalTo(-LDMargin_V*2)
        })
        
        statusLab?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo(jobTitleLab!.snp_bottom)
            make.height.equalTo(LDMargin_V*5)
            make.left.right.equalTo(jobTitleLab!)
            
        })
        
        phoneLab?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo(statusLab!.snp_bottom)
            make.left.right.height.equalTo(statusLab!)
            
        })
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
